<?php
/* @var $this ScheduleController */
/* @var $model Schedule */

$this->breadcrumbs=array(
	'Management'=>array('/site/management/'),
	'User Schedules',
);

$this->menu=array(
	//array('label'=>'List Schedule', 'url'=>array('index')),
	array('label'=>'Add Schedule', 'url'=>array('create', 'id'=>$model->iduser)),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#schedule-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage User Schedules</h1>
<p>


<h3>Select an User</h3>

<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::dropDownList('id',
						$model->iduser, 
						CHtml::listData(User::model()->findAll(array('condition'=>'team ='.Yii::app()->user->team_id, 'order'=>'username ASC')),
															   'iduser',
															   'username'),
						array('submit'=> CController::createUrl('schedule/admin'),
							  'empty'=> 'Select User',
							  'class' => 'dropusername',
							  )
						);
?>
<?php echo CHtml::endForm(); ?>


<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'schedule-grid',
	'dataProvider'=>$model->search($model->iduser),
	'summaryText' => '',
	'enableSorting' => false,
	'columns'=>array(
		array(
			'name'=>'weekday',
			'header'=>'Weekday',
			'value'=>'$data->weekday_relation->name',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),			
		array(
			'name'=>'shift',
			'header'=>'Shift',
			'value'=>'$data->shift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:90px; text-align:center;',
							 ),
		),	
		array(
			'name'=>'shift_start_time',
			'header'=>'Start Time',
			'value'=>'$data->shift_relation->start_time',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),		
		array(
			'name'=>'shift_end_time',
			'header'=>'End Time',
			'value'=>'$data->shift_relation->end_time',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),		
		array(
			'name'=>'qshift',
			'header'=>'Q-Shift',
			'value'=>'$data->qshift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:90px; text-align:center;',
							 ),
		),	
		array(
			'name'=>'qshift_start_time',
			'header'=>'Start Time',
			'value'=>'$data->qshift_relation->start_time',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),		
		array(
			'name'=>'qshift_end_time',
			'header'=>'End Time',
			'value'=>'$data->qshift_relation->end_time',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),		
		array(
			'class'=>'CButtonColumn',
			'header'=>'Actions',
			'template'=>'{view}{update}',
			'deleteConfirmation'=>'Are you sure you want to CANCEL this Shift Change?',
			'buttons'=>array(
						'view'=>array(
									'url'=>'Yii::app()->createUrl("schedule/view", array("id"=>$data->idschedule))',
									'label'=>'View Schedule',
									'options' => array('style'=>'width:10px;','title'=>'View Details')
								  ),
						'update'=>array(
									'url'=>'Yii::app()->createUrl("schedule/update", array("id"=>$data->idschedule))',
									'label'=>'Update Schedule',
									'options' => array('style'=>'width:10px;','title'=>'Update')
								  ),								  
						/*'del'=>array(
									'url'=>'Yii::app()->createUrl("schedule/delete", array("id"=>$data->idschedule))',
									'label'=>'Delete Schedule',
									'imageUrl' => Yii::app()->theme->baseUrl.'/images/delete.png',
									'options' => array('style'=>'width:10px;','title'=>'Delete Schedule')
								  ),
						*/
					   ),
		),
	),
)); ?>
